package com.example.rvdemo.simple;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.rvdemo.R;

import java.util.List;

public class RVSimpleAdaptar extends RecyclerView.Adapter<RVSimpleAdaptar.InnerHoder> {
    private Context context;
    private List<String> datas;

    public RVSimpleAdaptar(Context context, List<String> datas) {
        this.context = context;
        this.datas = datas;
    }

    @NonNull
    @Override
    public InnerHoder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.rv_simple_item, parent, false);
        return new InnerHoder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull InnerHoder holder, int position) {
        holder.textView.setText(datas.get(position));
        if (position % 3 == 0){
            holder.textView.setTextSize(30);
        }
    }

    @Override
    public int getItemCount() {
        return datas.size();
    }

    public class InnerHoder extends RecyclerView.ViewHolder {
        TextView textView;
        public InnerHoder(@NonNull View itemView) {
            super(itemView);
            textView = itemView.findViewById(R.id.tv_simple);
        }
    }
}
